import java.util.Scanner;

public class aaa {
    public static void main(String[] args) {
        //1.打印提示信息 欢迎来到猜数字
        System.out.println("欢迎来到猜数字");

        //2.生成数字
        int anser =  (int) (Math.random()*100+1);
        System.out.println(anser);
        //3.猜测数字
        Scanner num = new Scanner(System.in);
        int chances = 7 ;
        while(chances>0){
            //规定猜测次数
            System.out.println("请输入 1-100之间数字 "+"你还有"+chances+"机会");
            int guess = num.nextInt();

            //4.比较并完成
            if(guess>anser){
                System.out.println("猜大了");
            } else if (guess<anser) {
                System.out.println("猜小了");
            }else{
                System.out.println("猜对了");
                break;
            }

            chances --;

        }
    }
}
